#ifndef __BALLISTIC2D_H__
#define __BALLISTIC2D_H__
// Class calculates different values for the motion of a projectile in gravity field
// Current code assumes shooter coordinates are 0,0 , that may be changed in the future
// See unit test code in balistic.cpp for more examples how to use this class

class Ballistic2D {
private:
	int set; //find out which values are set
	float angle; // angle of the shooter
	float intialspeed; // the initial velocity
	float targetx; // the x value of where we want to hit
	float targety; // the y value of where we want to hit
	float xposition; // where the ballistic is on x coordinate plane
	float yposition; // where the ballistic is on a y coordinate plane
	float counter; //counter
public:
	void SetSpeed(float s); // function that sets our speed, given in m/s
	void SetAngle(float a); // function that sets our angle
	void SetTargetX(float x); // function that sets our xtarget
	void SetTargetY(float y); //function that sets our y target

	// Return x coordinates of projectile for given y coordinate, speed and
	// angle. All those should set before method is called. It may return up
	// to two x coordinates: one ascending and another descending
	// Returns B2D_SUCCESS if both x values are possible
	// Returns D2D_SUCCESS_1RESULT if only one x value is possible, x1 holds
	// the value, x2 is undefined
	// May return B2D_ERR_INVALIDARG, B2D_ERR_UNREACHABLE, in this case both
	// values of x1 and x2 are undefined
	int FindTargetX(float* x1, float* x2);

	// Returns y coordinates of a projectile for given x coordinate, speed and
	// angle. All of these should be set before method is called.
	// Returns B2D_SUCCESS if value was calculated correctly
	// May return B2D_ERR_INVALIDARG, in this case value of y is undefined
	// Note: it may return negative y values, in which case it will it still
	// return success - it means the shooting from the hill.
	int FindTargetY(float* y);

	// Returns the speed a projectile needs to achieve given x and y coordinates
	// at a certain angle. All of these should be set if method is called
	// Returns B2D_SUCCESS if value was calculated correctly
	// Returns B2D_ERR_UNREACHABLE if target is unreachable at current conditions
	// Returns B2D_ERR_INVALIDARG if some input values are missing
	int FindSpeed(float* speed);

	// Not implemented method, but when done should find angle given x and y
	// coordinates and speed.
	int FindAngle(float* angle);

};

#define B2D_SUCCESS 0 // returns this if the method worked
#define B2D_SUCCESS_1RESULT 1 // returns this if FindTargetX finds only 1 target
#define B2D_ERR_INVALIDARG 2 // returns this if all the necessary variables are not set
#define B2D_ERR_UNREACHABLE 3 // returns this if shot is unachievable in current conditions
#define B2D_ERR_UNIMPLEMENTED 4// returns this if method is FindAngle

#endif /* __BALLISTIC2D_H__ */

